package com.ale.oxetool;

import com.ale.oxetool.service.OXEServerSettings;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by guoshunw on 2016/3/30.
 */

@Configuration
public class ApplicationConfig {

    @ConfigurationProperties(prefix = "oxeserver.oxe1")
    @Bean
    public OXEServerSettings oxe1Settings() {
        return new OXEServerSettings();
    }

    @ConfigurationProperties(prefix = "oxeserver.oxe2")
    @Bean
//    @Qualifier("public")
    public OXEServerSettings oxe2Settings() {
        return new OXEServerSettings();
    }

    private static Logger log = LoggerFactory.getLogger(ApplicationConfig.class);

    @Bean
    public Map<String, String> phoneQmcduPrefixMap(@Value("${currentsite}") String currentSite) {

        Map<String, String> prefixMap = new HashMap<>();
        if ("south".equals(currentSite)) {
            prefixMap.put("1", "6");
            prefixMap.put("2", "8");
        } else if ("north".equals(currentSite)) {
            prefixMap.put("1", "1");
            prefixMap.put("2", "5");
        }
        return prefixMap;
    }
}
